class StudentManagementSystem:
    def __init__(self):
        """初始化学生列表"""
        self.students = []
    def add_student(self, student_id, name, age, major):
        """添加学生信息"""
        for student in self.students:
            if student['student_id'] == student_id:
                print(f"错误: 学号 {student_id} 已存在!")
                return False

        new_student = {
            'student_id': student_id,
            'name': name,
            'age': age,
            'major': major
        }

        self.students.append(new_student)
        print(f"成功添加学生: {name}(学号: {student_id})")
        return True

    def delete_student(self,student_id):
        """删除学生信息"""
        for i, student in enumerate(self.students):
            if student['student_id'] == student_id:
                deleted_name = self.students.pop(i)['name']
                print(f"已删除学生: {deleted_name} (学号: {student_id})")
                return True
            print(f"错误: 未找到学号为 {student_id} 的学生")
            return False
    def find_student(self, student_id):
        """查找学生信息"""
        for student in self.students:
            print("\n找到学生信息: ")
            print(f"学号: {student['student_id']}")
            print(f"姓名: {student['name']}")
            print(f"年龄: {student['age']}")
            print(f"专业: {student['major']}")
            return student
        print(f"未找到学号为 {student_id} 的学号")
        return None
    def show_all_students(self):
        """显示所有学生信息"""
        if not self.students:
            print("当前没有学生信息")
            return
        print("_" * 40)
        print(f" {len(self.students)} 名学生")
if __name__ == "__main__":
     sms = StudentManagementSystem()

     sms.add_student("1001","张三",20,"计算机科学")
     sms.add_student("1002","李四",21,"软件工程")
     sms.add_student("1003","王五",22,"数据科学")


     sms.show_all_students()


     sms.find_student("1002")

     sms.delete_student("1003")
     sms.show_all_students()